<?php $header=$this->action('ZfcAdmin\Controller\AdminController', 'headerAction');
	  $baseUrl = $header->headerarray['baseUrl'];
?>
<div class="main_title">
<div class="container">
	<h2>Edit Profile</h2>
</div>
</div>
<?php if(isset($_SESSION['user'])){?>
	<div class="container">
	<div class="row">
	<div class="span3">
	<div class="sub_header_left">
		<ul>
			<li>My Account</li>
			<?php if(isset($_SESSION['user'])){ ?>
			<li>
				<a href="<? echo $baseUrl;?>users/edit-user?user_id=<?php if(isset($_SESSION['user']['user_id'])){echo $_SESSION['user']['user_id'];}else{} ?>">Profile</a>
			</li>
			<li>
				<a href="<? echo $baseUrl;?>users/change-password">Change Password</a>
			</li>
			<?if($_SESSION['user']['user_type']=="user"){?>
			<li>
				<a href="<? echo $baseUrl;?>users/userorderview">Your Orders</a>
			</li>
			<? }else{?>
			<li><a href="<? echo $baseUrl;?>users/order-view">Online-Orders</a></li>
			<li><a href="<? echo $baseUrl;?>users/offline-order">Offline-orders</a></li>
			<?}?>
			<?php }?>
			<li><a href="#">Help Center</a></li>
		</ul>
	</div>
	</div>
	<div class="span9">
		<div class="well">
			<div class="inner_title">
				<h3>Edit Profile</h3>
			</div>
			<form class="form-horizontal" id="edit_form" name="edit_form" method="POST">
				<div class="control-group">
						<label class="control-label" for="inputUserName">User Name</label>
					<div class="controls">
						<input type="text" id="inputUserName" name="inputUserName" placeholder="User Name" value="<? if(isset($this->userdetails->user_name) && $this->userdetails->user_name!=""){echo $this->userdetails->user_name;}else{}?>">
					</div>
				</div>
				<div class="control-group">
						<label class="control-label" for="displayName">Display Name</label>
					<div class="controls">
						<input type="text" id="displayName" name="displayName" placeholder="Display Name" value="<? if(isset($this->userdetails->display_name) && $this->userdetails->display_name!=""){echo $this->userdetails->display_name;}else{}?>">
					</div>
				</div>
				<div class="control-group">
						<label class="control-label" for="inputEmail">Email Id</label>
					<div class="controls">
						<input type="text" id="inputEmail" name="inputEmail" placeholder="Email" value="<? if(isset($this->userdetails->email) && $this->userdetails->email!=""){echo $this->userdetails->email;}else{}?>" readonly>
					</div>
				</div>
				<div class="control-group">
						<label class="control-label" for="secondEmail">Secondary Email</label>
					<div class="controls">
						<input type="text" id="secondEmail" name="secondEmail" placeholder="Secondary Email" value="<? if(isset($this->userdetails->secondary_email) && $this->userdetails->secondary_email!=""){echo $this->userdetails->secondary_email;}else{}?>">
					</div>
				</div>
				<div class="control-group">
						<label class="control-label" for="inputPhone">Phone Number</label>
					<div class="controls">
						<input type="text" id="phoneNumber" name="phoneNumber" placeholder="phoneNumber" value="<? if(isset($this->userdetails->phone_number) && $this->userdetails->phone_number!=""){echo $this->userdetails->phone_number;}else{}?>">
					</div>
				</div>
				<div class="control-group">
						<label class="control-label" for="alternateNumber">Alternate Number</label>
					<div class="controls">
						<input type="text" id="alternateNumber" name="alternateNumber" placeholder="Alternate Number" value="<? if(isset($this->userdetails->alter_phone_mobile) && $this->userdetails->alter_phone_mobile!=""){echo $this->userdetails->alter_phone_mobile;}else{}?>">
					</div>
				</div>
				<div class="control-group">
						<label class="control-label" for="cityname">City Name</label>
					<div class="controls">
						<input type="text" id="cityname" name="cityname" placeholder="City Name" value="<? if(isset($this->userdetails->city_name) && $this->userdetails->city_name!=""){echo $this->userdetails->city_name;}else{}?>">
					</div>
				</div>
				<div class="control-group">
						<label class="control-label" for="address">Address</label>
					<div class="controls">
						<textarea  id="address" name="address" placeholder="Address"><? if(isset($this->userdetails->address) && $this->userdetails->address!=""){echo $this->userdetails->address;}else{}?></textarea>
					</div>
				</div>
				<div class="control-group">
						<label class="control-label" for="pincode">PinCode</label>
					<div class="controls">
						<input type="text" id="pincode" name="pincode" placeholder="PinCode" value="<? if(isset($this->userdetails->pincode) && $this->userdetails->pincode!=""){echo $this->userdetails->pincode;}else{}?>">
					</div>
				</div>
				<?php if($this->userdetails->user_type=='franchisee'){?>
					<div id="franchesediv">
						<div class="control-group">
							<label class="control-label" for="district">District:</label>
								<div class="controls">
									<select id="districts" name="districts" onChange="return getDistrictAreas('user_dist_areas','final');">
											<option value="">select a district</option>
											<? if($this->alldistricts->count()>0){ foreach($this->alldistricts as $district){ 
											if($this->userdetails->district_id==$district->district_id){?>
											<option value="<? echo $district->district_id;?>" selected="selected"><? echo $district->district_name;?></option>
											<?}else {?>
											<option value="<? echo $district->district_id;?>"><? echo $district->district_name;?></option>
											<?}?>
											<?}}else{?>
											<option value="">No districts</option>
											<?}?>
									</select>
								</div>	
						</div>
						<br/>
						<div class="control-group">
							<label class="control-label" for="area">Area:</label>
								<div class="controls">
									<select id="areas" name="areas" onChange="return getAreaBasedLocations('user_area_locations')">
										<option value="">select a area</option>	
										<? if($this->areasAll->count()>0){ foreach($this->areasAll as $areas){ 
										if($this->userdetails->area_id==$areas->area_id){?>
										<option value="<? echo $areas->area_id;?>" selected="selected"><? echo $areas->area_name;?></option>
										<?}else{?>
										<option value="<? echo $areas->area_id;?>"><? echo $areas->area_name;?></option>
										<?}?>
										<?}}else{?>
										<option value="">No areas</option>
										<?}?>
									</select>
								</div>
						</div>
						<br/>
						<div class="control-group">
							<label class="control-label" for="location">Location:</label>
								<div class="controls">
									<select id="location_id" name="location_id" >
										<option value="">select location</option>
										<? if($this->locationsAll->count()>0){ foreach($this->locationsAll as $locations){ 
										if($this->userdetails->location_id==$locations->location_id){?>
										<option value="<? echo $locations->location_id;?>" selected="selected"><? echo $locations->location_name;?></option>
										<?}else{?>
										<option value="<? echo $locations->location_id;?>"><? echo $locations->location_name;?></option>
										<?}?>
										<?}}else{?>
										<option value="">No locations</option>
										<?}?>
									</select>
								</div>	
						</div>
						<br/>
					</div>
					<?}?>
				<div class="control-group">
					<div class="controls">
						<button type="button" class="clf_btn"  onClick="return edituserValidations('user')">Update</button>
						<input type="hidden" id="hid_user_id" name="hid_user_id" 
						value="<? if(isset($this->userdetails->user_id) && $this->userdetails->user_id!=""){echo $this->userdetails->user_id;}else{}?>">
						<input type="hidden" id="hid_user_details_id" name="hid_user_details_id" 
						value="<? if(isset($this->userdetails->user_details_id) && $this->userdetails->user_details_id!=""){echo $this->userdetails->user_details_id;}else{}?>">
					</div>
				</div>
			</form>
		</div>
		</div>
	</div>
	</div>
<?php }else{?>
<script>
	window.location=BASE_URL;
</script>
<?php } ?>
	
	